package com.gxd.business.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gxd.business.bind.aop.FieldBind;
import com.gxd.business.constant.DictConstants;
import com.gxd.common.core.domain.MpBaseEntity;
import com.gxd.common.utils.GUID;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * @author gxd
 * @since 2025/6/13
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName(value = "t_product", autoResultMap = true)
@ApiModel(description = "产品表 实体类")
public class Product extends MpBaseEntity {

    /** id生成方式：GUID */
    public void setGUID() {
        this.id = new GUID().toString();
    }

    @ApiModelProperty(value = "产品Id")
    @TableId(type = IdType.INPUT)
    private String id;

    @ApiModelProperty(value = "产品名称")
    @NotEmpty(message = "产品名称不能为空")
    private String productName;

    @ApiModelProperty(value = "产品分类")
    @NotNull(message = "产品分类不能为空")
    @FieldBind(key = DictConstants.PRODUCT_TYPE, target = "productTypeMc")
    private Integer productType;

    @ApiModelProperty(value = "产品分类Mc")
    @TableField(exist = false)
    private String productTypeMc;

    @ApiModelProperty(value = "产品价格")
    @NotNull(message = "产品价格不能为空")
    private BigDecimal productPrice;

    @ApiModelProperty(value = "产品库存")
    @NotNull(message = "产品库存不能为空")
    private Integer productStock;

    @ApiModelProperty(value = "状态(1上架 2下架)")
    @NotNull(message = "状态不能为空")
    @FieldBind(key = DictConstants.PRODUCT_STATUS, target = "statusMc")
    private Integer status;

    @ApiModelProperty(value = "状态Mc")
    @TableField(exist = false)
    private String statusMc;

    @ApiModelProperty(value = "产品描述")
    private String productDescribe;

    @ApiModelProperty(value = "是否删除(0否 1是)")
    private Integer deleted;
}
